package com.copa.l2293;

/**
 * @author copa
 * @createDate 2023-01-15 0:54
 * @function 模拟法
 */
public class Test1 {

    public int minMaxGame(int[] nums) {
        if (nums.length == 1) {
            return nums[0];
        }
        int n = nums.length;
        while (n > 1) {
            int[] newNums = new int[n / 2];
            for (int i = 0; i < newNums.length; i++) {
                if (i % 2 == 0) {
                    newNums[i] = Math.min(nums[2 * i], nums[2 * i + 1]);
                    continue;
                }
                newNums[i] = Math.max(nums[2 * i], nums[2 * i + 1]);
            }
            nums = newNums;
            n /= 2;
        }
        return nums[0];
    }

    public static void main(String[] args) {
        int[] nums = {1,3,5,2,4,8,2,2};
        //int[] nums = {3};
        System.out.println(new Test1().minMaxGame(nums));
    }
}
